package com.fau.cm.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 话单记录表
 * @author liy
 * @datetime 2014年12月11日,上午2:15:17
 */
@Entity
@Table(name = "medical_call_record")
public class MedicalCallRecord implements Serializable, JSONAware {

	private static final long serialVersionUID = -6125056209041836953L;

	private String id;
	private String extension;	// 分机号码
	private String callNum;		// 呼出号码
	private String type;		// 计费类型
	private BigDecimal fee;		// 话费
	private Date callTime;		// 呼出时间
	private Date endTime;		// 挂机时间
	private Integer seconds;	// 通话时长
	private String relay;		// 中继
	private String eid;			// 企业Id
	
	private String typeValue;
	
	@Id
	@GenericGenerator(name = "generator", strategy = "assigned")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "extension", length = 7)
	public String getExtension() {
		return extension;
	}

	public void setExtension(String extension) {
		this.extension = extension;
	}

	@Column(name = "call_num", length = 15)
	public String getCallNum() {
		return callNum;
	}

	public void setCallNum(String callNum) {
		this.callNum = callNum;
	}

	@Column(name = "type", length = 30)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Column(name = "fee", length = 11)
	public BigDecimal getFee() {
		return fee;
	}

	public void setFee(BigDecimal fee) {
		this.fee = fee;
	}

	@Column(name = "call_time")
	public Date getCallTime() {
		return callTime;
	}

	public void setCallTime(Date callTime) {
		this.callTime = callTime;
	}

	@Column(name = "end_time")
	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	@Column(name = "seconds", length = 5)
	public Integer getSeconds() {
		return seconds;
	}

	public void setSeconds(Integer seconds) {
		this.seconds = seconds;
	}

	@Column(name = "relay", length = 20)
	public String getRelay() {
		return relay;
	}

	public void setRelay(String relay) {
		this.relay = relay;
	}

	@Column(name = "eid", length = 32)
	public String getEid() {
		return eid;
	}

	public void setEid(String eid) {
		this.eid = eid;
	}

	@Transient
	public String getTypeValue() {
		return typeValue;
	}

	public void setTypeValue(String typeValue) {
		this.typeValue = typeValue;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("id", id);
		jsonObject.put("extension", extension);
		jsonObject.put("callNum", callNum);
		jsonObject.put("type", type);
		jsonObject.put("typeValue", typeValue);
		jsonObject.put("fee", fee);
		jsonObject.put("callTime", DateFormatUtils.format(callTime, "yyyy-MM-dd HH:mm:ss"));
		jsonObject.put("endTime", DateFormatUtils.format(endTime, "yyyy-MM-dd HH:mm:ss"));
		jsonObject.put("seconds", seconds);
		jsonObject.put("relay", relay);
		jsonObject.put("eid", eid);
		return jsonObject.toString();
	}

}
